package com.zhiyou100.service.imp;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zhiyou100.IService.Iservice;
import com.zhiyou100.entity.ProsGyzc;
import com.zhiyou100.entity.ProsGyzcExample;
import com.zhiyou100.entity.ProsGyzcExample.Criteria;
import com.zhiyou100.entity.prosGo.TbProjects;
import com.zhiyou100.entity.prosGo.TbUser;
import com.zhiyou100.mapper.ProsGyzcMapper;
import com.zhiyou100.mapper.prosGo.TbProjectsMapper;
import com.zhiyou100.mapper.prosGo.TbUserMapper;

@Service
public class ServiceImp implements Iservice {

	@Resource
	private ProsGyzcMapper mapper;
	@Resource
	private TbProjectsMapper mapper2;
	@Resource
	private TbUserMapper mapper3;
	
	public List<ProsGyzc> selectGyzc(ProsGyzc p) {
		ProsGyzcExample example = new ProsGyzcExample();
		Criteria criteria = example.createCriteria();
		criteria.andPsStatusEqualTo(1);
		if (p.getPsPstId()!=null) {
			criteria.andPsPstIdEqualTo(p.getPsPstId());
			return mapper.selectByExample(example);
		}
		return mapper.selectByExample(example);
	}

	public List<ProsGyzc> selectByType(ProsGyzc p) {
		ProsGyzcExample example = new ProsGyzcExample();
		Criteria criteria = example.createCriteria();
		criteria.andPsStatusEqualTo(1);
		if (p.getPsType()!=null) {
			criteria.andPsTypeEqualTo(p.getPsType());
			return mapper.selectByExample(example);
		}
		return mapper.selectByExample(example);
	}

	public List<ProsGyzc> order(Integer num) {
		ProsGyzcExample example = new ProsGyzcExample();
		if (num!=null&&num==1) {
			example.setOrderByClause("ps_getpeople");
			return mapper.selectByExample(example);
		}
		if (num!=null&&num==2) {
			example.setOrderByClause("ps_getpeople desc");
			return mapper.selectByExample(example);
		}
		if (num!=null&&num==3) {
			example.setOrderByClause("ps_money");
			return mapper.selectByExample(example);
		}
		if (num!=null&&num==4) {
			example.setOrderByClause("ps_money desc");
			return mapper.selectByExample(example);
		}
		return mapper.selectByExample(null);
	}

	public TbProjects selectGyzcOne(TbProjects pro) {
		TbProjects p = mapper2.selectByPrimaryKey(pro.getPsId());
		return p;
	}
	public TbUser selectus(Integer id) {
		TbUser us = mapper3.selectByPrimaryKey(id);
		return us;
	}

}
